﻿namespace PowerSong.SongDatabase
    {
    using System;
    using System.IO;

    public class License : BaseEntity
        {

        public string Name { get; set; }

        public string Number { get; set; }

        public string Description { get; set; }

        public License()
            : this(string.Empty)
            {
            }

        public License(string name, string number = "", string description = "")
            : base(FileEntryType.License, 1)
            {
            this.Name = name;
            this.Number = number;
            this.Description = description;
            }

        internal override bool Deserialise(Database database, BinaryReader reader, int version)
            {

            // Ensure the version is correct
            if (version != 1) return false;

            // Get the details
            this.Name = reader.ReadString();
            this.Number = reader.ReadString();
            this.Description = reader.ReadString();
            
            // Details read in successfully
            return true;

            }

        internal override void Serialise(BinaryWriter writer)
            {
            writer.Write(Name);
            writer.Write(Number);
            writer.Write(Description);
            }

        public override string ToString()
            {
            return Name;
            }

        }

    }
